/**
 * Created by Andy on 2017/10/26.
 */
$(function () {
  var _SCROLL_TIME_STAMP = $.now();
  var sections = $('.section');
  var length = sections.length;
  console.log('this is sections ===>>', sections);
  showSection();
  /*注册事件*/
  var scrollFunc=function(e){
    var tempTimeStamp = $.now();
    var ee = e || window.event;
    if(tempTimeStamp - _SCROLL_TIME_STAMP > 50) {
      console.log('this is scroll ===>>', ee, ee.wheelDelta, ee.detail);
    }
    _SCROLL_TIME_STAMP = tempTimeStamp;
  }
  if(document.addEventListener){
    document.addEventListener('DOMMouseScroll',scrollFunc,false);
  }
  //W3C
  window.onmousewheel=document.onmousewheel=scrollFunc;//IE/Opera/Chrome

  $('.click_button').click(function (e) {
    console.log(e.target.id);
    


  });
  
  
  function showSection(data) {
    var showSection = data ? data : 1;
    for (var i=0; i< length; i++) {
      if(showSection == i) {
        $(sections[i]).show();
        var sectionW = $(sections[i]).width();
        var sectionH = $(sections[i]).height();
        var screenW = $(window).width();
        var screenH = $(window).height();
        console.log('this is sectionW sectionH ===>>', sectionW , sectionH);
        console.log('this is screenW screenH ===>>', screenW , screenH);
        if(sectionW > screenW) {
          $(sections[i]).css({
            "overflow-x": "auto"
          });
        } else {
          $(sections[i]).css({
            "overflow-x": "hidden"
          });
        }
        if(sectionH > screenH) {
          $(sections[i]).css({
            "overflow-y": "auto"
          });
        } else {
          $(sections[i]).css({
            "overflow-y": "hidden"
          });
        }
      } else {
        $(sections[i]).hide();
      }
    }
  }
});